﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using XYAuto.Utils.Data;

namespace XYAuto.MonitorData.Chitunion.Dal
{

    //数据库连接字符串表
    public partial class DataServceConnect : DataBase
    {


        public static readonly DataServceConnect Instance = new DataServceConnect();


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Insert(Entities.DataServceConnect entity)
        {
            var strSql = new StringBuilder();
            strSql.Append("insert into DataServceConnect(");
            strSql.Append("DataName,DataConnect,CreateTime,CreateUserId,UpdateTime,UpdateUserId");
            strSql.Append(") values (");
            strSql.Append("@DataName,@DataConnect,@CreateTime,@CreateUserId,@UpdateTime,@UpdateUserId");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            var parameters = new SqlParameter[]{
                        new SqlParameter("@DataName",entity.DataName),
                        new SqlParameter("@DataConnect",entity.DataConnect),
                        new SqlParameter("@CreateTime",entity.CreateTime),
                        new SqlParameter("@CreateUserId",entity.CreateUserId),
                        new SqlParameter("@UpdateTime",entity.UpdateTime),
                        new SqlParameter("@UpdateUserId",entity.UpdateUserId),
                        };


            var obj = SqlHelper.ExecuteScalar(CONNECTIONSTRINGS, CommandType.Text, strSql.ToString(), parameters);
            return obj == null ? 0 :

                Convert.ToInt32(obj);

        }
    }
}

